<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="./static/layui/css/layui.css">
	</head>
	<body>
		<form class="layui-form" action="integralupdate.do" method="post">
			<div class="layui-form-item" hidden>
				<label class="layui-form-label" >id</label>
				<div class="layui-input-block">
					<input type="text" name="id" lay-verify="title" autocomplete="off" placeholder="请输入用户名"
						   class="layui-input"  value="${integral.id}">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">用户名</label>
				<div class="layui-input-block">
					<input type="text" name="username" lay-verify="title" autocomplete="off" placeholder="请输入用户名"
						   class="layui-input" readonly value="${integral.username}">
<%--					<select lay-filter="username" name="username" id="username" onchange="chanum()">--%>
<%--						<option class="" value="0">请选择</option>--%>
<%--					</select>--%>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">积分</label>
				<div class="layui-input-block">
					<input  id="num" type="number" name="integral" lay-verify="title" autocomplete="off" placeholder="请输入密码"
						class="layui-input" value="${integral.integral}">
				</div> 
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="submit" onclick="updateInt()" class="layui-btn" lay-submit="" lay-filter="demo1" >立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
	</body>
	<script type="text/javascript" src="./static/js/jquery-3.4.1.min.js"></script>
	<script type="text/javascript" src="./static/layui/layui.js"></script>
	<script type="text/javascript">
		layui.use(['form', 'layedit', 'laydate'], function() {
			var form = layui.form,
				layer = layui.layer,
				layedit = layui.layedit,
				laydate = layui.laydate;
		
			//创建一个编辑器
			var editIndex = layedit.build('LAY_demo_editor');
		
			form.on('select(username)',function(data){
				category = data.value;
				console.log(data)
				console.log(this)
				username = data.elem[data.elem.selectedIndex].text;
				form.render('select')
			});
			//监听提交
			// form.on('submit(demo1)', function(data) {
			// 	return false;
			// }

			);
		});
	</script>
	<script>
		// var un = document.getElementById("username");
		// function userName(){
		// 	$.post("http://121.196.194.191:8082/queryUsernameAll.action",function(data){
		// 		var name = data.usernames;
		// 		for (var i in name) {
		// 			un.innerHTML += `<option class="op" value='` + name[i].uid + `'>` + name[i].userName + `</option>`
		// 		}
		// 	});
		// 	layui.use('form',function(){
		// 		var form = layui.form;
		// 		form.render('select');
		// 	});
		// }
		// window.onload=userName();
		//
		// function chanum(){
		// 	uid = un.value;
		// 	$.post("http://121.196.194.191:8082/queryIntegralByUid.action",{uid:uid},function(data){
		// 		var num = data.num;
		// 		document.getElementById("num").value = num;
		// 	})
		// 	console.log('a');
		// }
		//
		// function updateInt(){
		// 	uid = un.value;
		// 	num = document.getElementById("num").value;
		// 	$.post("http://121.196.194.191:8082/updateIntegral.action",{uid:uid,num:num},function(data){
		// 		if(data.status=="200"){
		// 			window.location.href = "integrallist.html";
		// 		}else {
		// 			alert("修改失败")
		// 		}
		//
		// 	})
		//
		// }
		
	</script>
</html>
